import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询新闻列表
export function listArticle(query) {
  return request({
    url: '/system/article/list',
    method: 'get',
    params: query
  })
}

// 新闻状态修改
export function changeArticleStatus(articleId, status) {
  const data = {
    articleId,
    status
  }
  return request({
    url: '/system/article/changeStatus',
    method: 'put',
    data: data
  })
}

// 查询新闻详细
export function getArticle(articleId) {
  return request({
    url: '/system/article/' + parseStrEmpty(articleId),
    method: 'get'
  })
}

// 查询新闻详细
export function getInfoByType(query) {
  return request({
    url: '/system/article/getInfoByType?articleType=' + query.articleType + '&tenantId=' + query.tenantId + '&cateId=' + query.cateId,
    method: 'get'
  })
}

// 新增新闻
export function addArticle(data) {
  return request({
    url: '/system/article',
    method: 'post',
    data: data
  })
}

// 修改新闻
export function updateArticle(data) {
  return request({
    url: '/system/article',
    method: 'put',
    data: data
  })
}

// 修改新闻
export function editArticle(data) {
  return request({
    url: '/system/article/editArticle',
    method: 'post',
    data: data
  })
}

// 删除新闻
export function delArticle(articleId) {
  return request({
    url: '/system/article/' + articleId,
    method: 'delete'
  })
}

// 查询分类下拉树结构
export function cateTreeSelect(query) {
  return request({
    url: '/system/article/cateTree',
    method: 'get',
    params: query
  })
}
